package com.geekbang.learngenerics.define;

// >> TODO 定义泛型，就是把需要的类型定义在类后面的尖括号里，然后在类里面就可以把定义好的泛型像符号一样使用
// >> TODO https://www.cnblogs.com/iyangyuan/archive/2013/04/09/3011274.html
// >> TODO https://segmentfault.com/a/1190000014824002
// >> TODO https://segmentfault.com/a/1190000039791306?_ea=121520780

public class MyGenericClass<First, Second> {

    // >> TODO 实际上这两个引用都是Object类型的
    private First first;

    private Second second;

    public MyGenericClass(First first, Second second) {
        this.first = first;
        this.second = second;
    }

    public First getFirst() {
        return first;
    }

    public void setFirst(First first) {
        this.first = first;
    }

    public Second getSecond() {
        return second;
    }

    public void setSecond(Second second) {
        this.second = second;
    }

    // TODO 泛型方法 返回值由调用的时候 定义的
    public <Another> Another getAnother(Object val) {
        return (Another) val;
    }

}
